//
//  SESSFileLookController.m
//  MarketingApp
//
//  Created by 李叶夫 on 2018/5/10.
//  Copyright © 2018年 李叶夫. All rights reserved.
//

#import "SESSFileLookController.h"
#import "LLFileLookView.h"

@interface SESSFileLookController ()
@property (strong, nonatomic) NSURL *filePath;
@property (strong, nonatomic) UIView *navi;

@end

@implementation SESSFileLookController

- (instancetype)initWithFilePath:(NSURL *)filePath
{
    if (self = [super init]) {
        self.filePath = filePath;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, safeAreaTopHeight)];
    self.navi.backgroundColor = [UIColor whiteColor];
    UIButton *back = [[UIButton alloc] initWithFrame:CGRectMake(16, safeAreaTopHeight-44, 50, 44)];
    [back setImage:[UIImage imageNamed:@"close2"] forState:UIControlStateNormal];
    [back setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 35)];
    [back addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    [self.navi addSubview:back];
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth-200)/2, safeAreaTopHeight-44, 200, 44)];
    title.font = [UIFont boldSystemFontOfSize:17];
    title.text = @"查看附件";
    title.textAlignment = NSTextAlignmentCenter;
    [self.navi addSubview:title];
    [self.view addSubview:self.navi];
    
    LLFileLookView *lookView = [[NSBundle mainBundle] loadNibNamed:@"LLFileLookView" owner:nil options:nil].lastObject;
    lookView.filePath = self.filePath;
    lookView.frame = CGRectMake(0, safeAreaTopHeight, kScreenWidth, kScreenHeight-safeAreaTopHeight);
    [self.view addSubview:lookView];
}

- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    
}

- (void)back:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
